{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "modified-watson",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/random-pick-index\n",
    "\n",
    "\n",
    "Runtime: 320 ms, faster than 42.00% of Python3 online submissions for Random Pick Index.\n",
    "Memory Usage: 23.1 MB, less than 47.74% of Python3 online submissions for Random Pick Index.\n",
    "\n",
    "\n",
    "```python\n",
    "import random\n",
    "\n",
    "class Solution:\n",
    "\n",
    "    def __init__(self, nums: List[int]):\n",
    "        self.d = dict()\n",
    "        for i, v in enumerate(nums):\n",
    "            if v not in self.d:\n",
    "                self.d[v] = [i]\n",
    "            else:\n",
    "                self.d[v].append(i)\n",
    "\n",
    "    def pick(self, target: int) -> int:\n",
    "        #6:40\n",
    "        return random.choice(self.d[target])\n",
    "        #6:42\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "adult-alert",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
